package binpacking.io;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Randomizer {
	
	
	/* Creates an "amount" of integers between 0 and "high" and saves this to "fileName" */
	public Randomizer( int amount, int high, String fileName ) {
		File file = new File( fileName );
		BufferedWriter output;
		try {
			output = new BufferedWriter( new FileWriter( file ) );
			
			for( int i = 0; i < amount; i ++ ) {
				// high +1 to enable also the highest amount to be generated as Math.random generates less than 1.0
				int random = ( int ) ( Math.random() * (high+1) );
				output.write( random + "\n" );
			}
			output.close();
		} catch( IOException e ) {
			System.out.println( "Error in Randomizer: " +  e.getMessage() );
		}
	}

}

